with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
with Rational_Numbers.Io;
with Rational_Numbers.Components ;use Rational_Numbers.Components;
package body Rational_Numbers.Io is

   -- get standard
   procedure Get
     (R : out Rational;
      Width_Of_Numerator, Width_Of_Denominator : in Field := 0) is
   begin
      Get(Current_Input,R, Width_Of_Numerator, Width_Of_Denominator);
   end Get;

   procedure Get
     (F : File_Type;
      R : out Rational;
      Width_Of_Numerator, Width_Of_Denominator : in Field := 0) is
      Buffer : Character ;
      Numerator , Denominator : Integer := 0;

   begin

      Get(F,Numerator,Width_Of_Numerator);
      loop
         Get(F,Buffer);
         case Buffer is
            when Separator => exit;
            when ' '=> null;
            when others => raise Data_Error;
         end case ;
      end loop;
      Get(F,Denominator,Width_Of_Denominator);
      R:= Numerator / Denominator; -- ici / est le constructeur de rational
                                  --      return R; ets inutile car R est une variable sortante;
   end Get;


   Procedure Put
     (R : Rational;
      Width_Of_Numerator, Width_Of_Denominator : in Field := Default_Width) is
   begin
      Put(Current_Output ,R, Width_Of_Numerator, Width_Of_Denominator);
   end Put;

   procedure Put
     (F : File_Type;
      R : Rational;
      Width_Of_Numerator, Width_Of_Denominator : in Field := Default_Width)is
   begin
      Put(F,Numerator(R),Width_Of_Numerator);
      Put(F,Separator);
      Put(F,Denominator(R),Width_Of_Denominator);
   end Put;

end Rational_Numbers.Io;
